var jForms = {
		validate: function(){
					var r = false;
					var target = this;
					function createErrorMsg(obj, error){
						var msg = jarvis.create('div');
						msg.className = "jarvisErrorMsgFormValidation";
						msg.$$("backgroundColor","#333333").$$("color","white").$$("position","absolute").$$("left", obj.gL()+ "px").$$("top", obj.gT()-34+ "px").$$("padding","5px");
						msg.innerText = error;
						obj.error = msg;
						document.body.appendChild(msg);
					}
					var integer=/\d/gi;
					var float=/[\d.]/gi;
					var email=/[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}/gi;
						
					this.find('.required').each(function(el){
													if(el.className.indexOf('required[') > -1){ //if it has some options in [ ]
														var filtro = el.className.split('required[');
														filtro = filtro[1].substr(0, filtro[1].indexOf(']'));
														switch(filtro){
															case "email":
																el.onblur = function(e){
																					if(el.value.trim() != "" && email.test(el.value.trim())){
																						r = true;
																						if(el.error) el.error.$$("display","none");
																					} else {
																						createErrorMsg(el, "This is not a valid email");
																					}
																				}
															break;
														}
													}
												});
					
					function isValidEmail(value){
						return email.test(value);
					}
					
					function frmSubmit(){
						this.find('.required').each(function(el){
							switch(el.type){
								case "text":
									if(el.value.trim() == ""){
										createErrorMsg(el, "This can't be empty");
										r = false;
									}
								break;
							}
						});
						return r;
					}
					
					this.onsubmit = frmSubmit;
					return this;
				 }
}
jarvis.extend(jForms);